import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		userInfo: {}
	},
	mutations: {
		login(state, provider) {
			state.userInfo.token = provider.token
			state.userInfo.userId = provider.user_id
			uni.setStorage({
				key: 'userInfo',
				data: provider
			})
			uni.setStorage({
				key: 'token',
				data: provider.token
			})
		},
		logout(state) {
			state.userInfo = {}
			uni.removeStorage({
				key: 'userInfo'
			});
			uni.removeStorage({
				key: 'token'
			})
			// uni.removeStorage({
			// 	key: 'HCmobile'
			// })
			// uni.removeStorage({
			// 	key: 'HCpassword'
			// })
			uni.removeStorage({
				key: 'intType'
			})
		}
	}
})

export default store
